home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / prolog / sbprolog / amiga / cmplibsr.zoo / $aux1.P < prev    next >
Text File  |  1988-09-15  |  4KB  |  115 lines

  1. /************************************************************************
  2. *                                    *
  3. * The SB-Prolog System                            *
  4. * Copyright SUNY at Stony Brook, 1986; University of Arizona,1987    *
  5. *                                    *
  6. ************************************************************************/
  7.  
  8. /*-----------------------------------------------------------------
  9. SB-Prolog is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY.  No author or distributor
  11. accepts responsibility to anyone for the consequences of using it
  12. or for whether it serves any particular purpose or works at all,
  13. unless he says so in writing.  Refer to the SB-Prolog General Public
  14. License for full details.
  15.  
  16. Everyone is granted permission to copy, modify and redistribute
  17. SB-Prolog, but only under the conditions described in the
  18. SB-Prolog General Public License.   A copy of this license is
  19. supposed to have been given to you along with SB-Prolog so you
  20. can know your rights and responsibilities.  It should be in a
  21. file named COPYING.  Among other things, the copyright notice
  22. and this notice must be preserved on all copies. 
  23. ------------------------------------------------------------------ */
  24.  
  25.  
  26.  
  27. /*  ------------------------------ aux1.P ------------------------------ */
  28.  
  29. /* **********************************************************************
  30. $aux1_export([$roundtosq/2,$get_compiletime/2,$message1/1, $output_msg/3,
  31.           $umsg/1,$name_aslfile/2,disj_targ_label/2,$gensym_pred/2,
  32.           $logical_or/3,$concat_atom/3]).
  33.  
  34. $aux1_use($name,[$name/2,_]).
  35. $aux1_use($blist,[$append/3,$member/2,$member1/2]).
  36. $aux1_use($bio,[$writename/1,$writeqname/1,$put/1,$nl/0,$tab/1,$tell/1,
  37.     $telling/1,$told/0,$get/1,$get0/1,$see/1,$seeing/1,$seen/0]).
  38. $aux1_use($glob,[_,_,$gensym/2]).
  39. ********************************************************************** *
  40.  
  41.  
  42. /* convert a round list to a square list */
  43.  
  44. $roundtosq(','(F,R),[F|Tr]) :- !, $roundtosq(R,Tr).
  45. $roundtosq(X,[X]) :- !.
  46. $roundtosq(true,[]).
  47.  
  48. $get_compiletime(CTime,Time) :- CTime0 is (CTime + 5)/1000.0,
  49.     $name(CTime0,N0),
  50.     $get_2dec_places(N0,N1),
  51.     $name(Time,N1).
  52.  
  53. $get_2dec_places([46|L],[46,D0,D1]) :-
  54.     $length(L,N),
  55.     (N >= 2 ->
  56.         L = [D0,D1|_] ;
  57.         (N =:= 1 -> (L = [D0], D1 = 48) ;
  58.                 (D0 = 48, D1 = 48)
  59.         )
  60.     ).
  61. $get_2dec_places([X|L],[X|L0]) :- X =\= 46, $get_2dec_places(L,L0).
  62. $get_2dec_places([],[]).
  63.  
  64. $message1(Opts) :- $member1(v,Opts), !,
  65.           $writename(' - translation phase commenced'),nl.
  66. $message1(_).
  67.  
  68. $output_msg(P,N,Opts) :-
  69.       (($member1(v,Opts),
  70.         !,
  71.         $telling(X), $tell(user),
  72.     $tab(15),
  73.         $writename('translating : '),
  74.     $writename(P), $writename('/'), $writename(N), $nl, $told,
  75.     $tell(X)
  76.        ) ;
  77.        true
  78.       ).
  79.  
  80. $umsg( Text ) :- $telling( File ), $tell( user ),
  81.     $umsg0( Text ), $nl, $told, $tell( File).
  82.  
  83. $umsg0([]) :- !.
  84. $umsg0([H|T]) :- !, $writename(H), $writename(' '), $umsg0(T).
  85. $umsg0(Atom) :- $writename(Atom).
  86.  
  87. $name_aslfile(InFile, AslFile) :-
  88.     $name(InFile,InFileName), $append(InFileName, ".asl", OutFile1Name),
  89.     $name(AslFile, OutFile1Name).
  90.  
  91. $disj_targ_label(Label,Name) :- $name(Label,Name1), $name(Name,[100|Name1]).
  92.  
  93. $gensym_pred(P,NP) :-
  94.     $name(P, Pname),
  95.     $gensym('_#',N2),
  96.     $name(N2,Nname2),
  97.     $append(Pname, Nname2, NPname), 
  98.     $name(NP,NPname).
  99.  
  100. $logical_or(X,Y,Z) :-
  101.     ((X =:= 1, Z = 1) ;
  102.      (X =\= 1,
  103.       ((Y =:= 1, Z = 1) ;
  104.        (Y =\= 1, Z = 0)
  105.       )
  106.      )
  107.     ).
  108.  
  109. $concat_atom(L1,L2,L3) :-
  110.     $name(L1,L1name), $name(L2,L2name),
  111.     $append(L1name,L2name,L3name),$name(L3,L3name).
  112.  
  113. /* ---------------------------------------------------------------------- */
  114.  
  115.